package cn.shenlong.front.directive;

import static freemarker.template.ObjectWrapper.DEFAULT_WRAPPER;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import cn.shenlong.domain.ContentBO;
import cn.shenlong.front.directive.abs.AbstractContentDirective;
import cn.shenlong.util.DirectiveUtils;
import freemarker.core.Environment;
import freemarker.template.TemplateDirectiveBody;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;

/**
 * 文章列表标签,继承通用抽象文章类
 * 
 */
@Component("front_content_list")
public class ContentListDirective extends AbstractContentDirective {

	@Override
	@SuppressWarnings({ "rawtypes" })
	public void execute(Environment env, Map params, TemplateModel[] loopVars,
			TemplateDirectiveBody body) throws TemplateException, IOException {
		// List<ContentBO> contentBoList = (List<ContentBO>)getData(params,
		// env);
		List<ContentBO> contentBoList = new ArrayList<ContentBO>();
		ContentBO c = new ContentBO();
		c.setTitle("1111");
		contentBoList.add(c);
		env.setVariable(DirectiveUtils.OUT_LIST,
				DEFAULT_WRAPPER.wrap(contentBoList));
		body.render(env.getOut());
	}

	// 非文章分页标签
	@Override
	protected boolean isPage() {
		return false;
	}

}
